package simulator.enums;

public enum EntityType
{
	CAR("car", true),
	BUS("bus", true),
	PED("pedestrian", false),
	BIKE("bike", false);
	
	private String _name;
	private boolean _hasLoops;
	
	private EntityType(String name, boolean hasLoops)
	{
		_name = name;
		_hasLoops = hasLoops;
	}
	
	public String getName()
	{
		return _name;
	}
	
	public boolean hasLoops()
	{
		return _hasLoops;
	}
	
	public static EntityType fromString(String str)
	{
		if("pedestrian".equalsIgnoreCase(str) || "ped".equalsIgnoreCase(str))
			return PED;
		if("car".equalsIgnoreCase(str) || "truck".equalsIgnoreCase(str))
			return CAR;
		if("bus".equalsIgnoreCase(str))
			return BUS;
		if("bike".equalsIgnoreCase(str) || "bicycle".equalsIgnoreCase(str))
			return BIKE;
		
		if("godzilla".equalsIgnoreCase(str)) /* actually in the specification */
			System.err.println("Godzilla ate the simulator!");
		
		return null;
	}
}
